<?php
mysql_query("CREATE TABLE IF NOT EXISTS articles (id mediumint(8) unsigned NOT NULL auto_increment, subId smallint(6) NOT NULL, guid_prefix varchar(13) collate utf8_unicode_ci NOT NULL, guid varchar(256) collate utf8_unicode_ci default NULL, pubDate datetime NOT NULL, title tinytext collate utf8_unicode_ci, link tinytext collate utf8_unicode_ci, description mediumtext collate utf8_unicode_ci NOT NULL, category tinytext collate utf8_unicode_ci, state set('new','starred','unread','open') collate utf8_unicode_ci default 'new', PRIMARY KEY (id), UNIQUE KEY guid (guid), KEY subId (subId), KEY pubDate (pubDate), KEY `status` (state,pubDate), FULLTEXT KEY title (title), FULLTEXT KEY link (link), FULLTEXT KEY description (description)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci PACK_KEYS=1", $link);
if (mysql_errno($link) !== 0) {
	// Try for MySQL < 4.1
	mysql_query("CREATE TABLE IF NOT EXISTS articles (id mediumint(8) unsigned NOT NULL auto_increment, subId smallint(6) NOT NULL, guid_prefix varchar(13) NOT NULL, guid varchar(255) default NULL, pubDate datetime NOT NULL, title tinytext, link tinytext, description mediumtext NOT NULL, category tinytext, state set('new','starred','unread','open') default 'new', PRIMARY KEY (id), UNIQUE KEY guid (guid), KEY subId (subId), KEY pubDate (pubDate), KEY `status` (state,pubDate), FULLTEXT KEY title (title), FULLTEXT KEY link (link), FULLTEXT KEY description (description)) ENGINE=MyISAM", $link)
		or die("Failed CREATE articles TABLE: " . mysql_error() . "\n");
}
mysql_query("CREATE TABLE IF NOT EXISTS subscriptions (id smallint(5) unsigned NOT NULL auto_increment, url tinytext collate utf8_unicode_ci, title tinytext collate utf8_unicode_ci, PRIMARY KEY (id), UNIQUE KEY url (url(256))) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", $link);
if (mysql_errno($link) !== 0) {
	// Try for MySQL < 4.1
	mysql_query("CREATE TABLE IF NOT EXISTS subscriptions (id smallint(5) unsigned NOT NULL auto_increment, url tinytext, title tinytext, PRIMARY KEY (id), UNIQUE KEY url (url(255))) ENGINE=MyISAM", $link)
		or die("Failed CREATE subscriptions TABLE: " . mysql_error() . "\n");
}
?>